String clazzTpl({package}) => """
enum AppDebugKey {
  debugBanner,
  policy,
  dev,
  proxy,
  hosts,
  h5FaceHosts,
  documentDir,
  themes,
  websocket,
  cleanMock,
  programMode,
  jsCoreMode,
}

class DataModel {
  late String key;
  late String value;
  late bool isDef;

  DataModel({required this.key, required this.value, this.isDef = false});

  DataModel.fromJson(Map<String, dynamic> json) {
    key = json['key'];
    value = json['value'];
    isDef = json['isDef'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['key'] = key;
    data['value'] = value;
    data['isDef'] = isDef;
    return data;
  }
}

class AppDebugModel {
  late AppDebugKey key;
  late String title;
  late bool on;
  String? desc;
  String? port;
  List<DataModel>? childList;

  AppDebugModel({
    required this.key,
    required this.title,
    this.on = true,
    this.desc,
    this.port,
    this.childList,
  });

  static AppDebugKey formatAppDebugKey(String key) {
    switch (key) {
      case 'debugBanner':
        return AppDebugKey.debugBanner;
      case 'policy':
        return AppDebugKey.policy;
      case 'dev':
        return AppDebugKey.dev;
      case 'proxy':
        return AppDebugKey.proxy;
      case 'hosts':
        return AppDebugKey.hosts;
      case 'h5FaceHosts':
        return AppDebugKey.h5FaceHosts;
      case 'documentDir':
        return AppDebugKey.documentDir;
      case 'themes':
        return AppDebugKey.themes;
      case 'websocket':
        return AppDebugKey.websocket;
      case 'cleanMock':
        return AppDebugKey.cleanMock;
      case 'programMode':
        return AppDebugKey.programMode;
      case 'jsCoreMode':
        return AppDebugKey.jsCoreMode;
      default:
        return AppDebugKey.debugBanner;
    }
  }

  AppDebugModel.fromJson(Map<String, dynamic> json) {
    key = formatAppDebugKey(json['key']);
    title = json['title'];
    on = json['on'];
    desc = json['desc'];
    port = json['port'];
    if (json['childList'] != null) {
      childList = (json['childList'] as List)
          .map((e) => DataModel.fromJson(e))
          .toList();
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['key'] = key.name;
    data['title'] = title;
    data['on'] = on;
    data['desc'] = desc;
    data['port'] = port;
    if (childList != null) {
      data['childList'] = childList!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class ErrorLogFileModel {
  final String path;
  final String title;
  final bool isFile;

  const ErrorLogFileModel(
      {required this.path, required this.title, required this.isFile});
}

class ClickContinuous {
  static DateTime _lastTime = DateTime.now();
  static int _clickNum = 0;

  static void clickCheck({int num = 10, int time = 2000, void Function()? cb}) {
    if (DateTime.now().difference(_lastTime) > Duration(milliseconds: time)) {
      _lastTime = DateTime.now();
      _clickNum = 0;
    } else {
      _clickNum++;
      if (_clickNum >= num) {
        _lastTime = DateTime.now();
        _clickNum = 0;
        if (cb != null) {
          cb();
        }
      }
    }
  }
}
""";
